package cn.dust.design.pattern.behavioral.memento;

/**
 * @Author: dust
 * @Date: 2019/11/28 16:53
 */
public class Test {
    public static void main(String[] args) {
        ArticleMementoManager articleMementoManager=new ArticleMementoManager();
        Article article=new Article("设计模式","内容","图片");
        ArticleMemento articleMemento=article.saveToMemento();
        articleMementoManager.addMemento(articleMemento);
        System.out.println("标题："+article.getTitle()+" 内容："+article.getContent()+" 图片："+article.getImgs());
        System.out.println("手记完整信息："+article);
        System.out.println("修改手记");
        article.setTitle("JavaHeadFirst");
        article.setContent("这是基础");
        article.setImgs("cool");
        System.out.println(article);
        articleMemento=article.saveToMemento();
        articleMementoManager.addMemento(articleMemento);

        article.setTitle("c");
        article.setContent("c");
        article.setImgs("c");
        articleMemento=articleMementoManager.getMemento();
        article.undoFromMemento(articleMemento);

        System.out.println(article+"back1");
        articleMemento=articleMementoManager.getMemento();
        article.undoFromMemento(articleMemento);
        System.out.println(article+"back2");



    }
}
